<template>
	<view style="width: 750rpx;padding-bottom: 30rpx;">
		<view style="width: 690rpx;height: 76rpx;margin-left: 30rpx;">
			<view style="font-size: 44rpx;line-height: 44rpx;padding-top: 32rpx;float: left;">{{jiedao1}}防汛检查</view>
			<view v-if="level!=4 && level!=5">
				<image src="../../static/btn-screenArrow@3x.png"style="width: 32rpx;height: 32rpx;float: right;margin-left: 10rpx;padding-top: 44rpx;" @click="goto()"></image>
				<view style="float: right;font-size: 32rpx;line-height: 32rpx;padding-top: 44rpx;" @click="goto()">{{jiedao}}</view>
			</view>
		</view>
		<view style="height: 162rpx;width: 690rpx;margin-left: 30rpx;">
			<view v-if="light">	
				<view style="float: left;" >
					<view style="font-size: 40rpx;line-height: 40rpx;padding-top: 60rpx;">检查进度</view>
					<view style="width: 80rpx;height: 6rpx;margin-left: 40rpx;margin-top: 16rpx;background-color: #333333;border-radius: 3rpx;"></view>
				</view>
				
				<view style="float: left;"@click="Light()" >
					<view style="font-size: 32rpx;line-height: 32rpx;padding-top: 68rpx;margin-left: 80rpx;">隐患整改</view>
				</view>
			</view>
			<view v-else>
				<view style="float: left;" @click="Lights()">
					<view style="font-size: 32rpx;line-height: 40rpx;padding-top: 60rpx;">检查进度</view>
				</view>
				<view style="float: left;">
					<view style="font-size: 40rpx;line-height: 40rpx;padding-top: 60rpx;margin-left: 80rpx;">隐患整改</view>
					<view style="width: 80rpx;height: 6rpx;margin-left: 120rpx;margin-top: 16rpx;background-color: #333333;border-radius: 3rpx;"></view>
				</view>
			</view>
		</view>
		<view v-if="light" style="padding-bottom: 160rpx;">
			<view style="width: 690rpx;height: 32rpx;margin-left: 30rpx;">
				<view style="float: left;font-size: 32rpx;line-height: 32rpx;">已创建检查</view>
				<image src="../../static/btn-screenArrow@3x.png"style="width: 32rpx;height: 32rpx;float: left;margin-left: 10rpx;"></image>
			</view>
			<view v-if="list.length!=0">
				<view style="width: 690rpx;border-radius: 12rpx;background-color: #FFFFFF;margin-left: 30rpx;margin-top: 20rpx;padding-bottom: 30rpx;" v-for="(item,index) in list" :key="index" >
					<view @click="gotoQ(item.name,item.range,item.startTime,item.endTime)" v-if="item.range!=null">
						<view style="width: 128rpx;height: 40rpx;background-image: linear-gradient(to right, #FF952C , #FFA940);color: #FFFFFF;border-top-left-radius:12rpx;
						border-top-right-radius:0;border-bottom-right-radius:12rpx;border-bottom-left-radius:0;font-size: 26rpx;line-height: 40rpx;text-align: center;" >
						区级任务</view>
						<view style="display: flex;">
							<view style="font-size: 36rpx;line-height: 36rpx;margin-top: 20rpx;margin-left: 30rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 270rpx;">{{item.name}}</view>
							<view style="width: 116rpx;height: 36rpx;background-color: rgba(251, 154, 23, 0.11);margin-top: 20rpx;margin-left: 16rpx;color: #FB9A17;text-align: center;font-size: 24rpx;line-height: 36rpx;border-radius: 4rpx;">待检查{{item.count}}</view>
							<view v-if="item.endTm<nowDate" style="display: flex;">
								<image src="../../static/icon_04@3x.png" style="width: 40rpx;height: 40rpx;margin-left: 80rpx;margin-top: 16rpx;"></image>
								<view style="color: #FB9A17;font-size: 32rpx;line-height: 32rpx;margin-left: 6rpx;margin-top: 20rpx;">已逾期</view>
							</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;color: #E93B3D;margin-top: 16rpx;margin-left: 30rpx;">{{parseInt(item.startTime.split('-')[1])}}月{{parseInt(item.startTime.split('-')[2].split(' ')[0])}}日～{{parseInt(item.endTime.split('-')[1])}}月{{parseInt(item.endTime.split('-')[2].split(' ')[0])}}日截止</view>
						<view style="color: #999999;font-size: 24rpx;line-height: 24rpx;margin-top: 30rpx;margin-left: 30rpx;">创建时间：{{item.createTime}}</view>
					</view>	
					<view @click="gotoQ(item.name,item.range,item.startTime,item.endTime)" v-else-if="item.range==null" style="padding-top: 20rpx;">
						<view style="display: flex;">
							<view style="font-size: 36rpx;line-height: 36rpx;margin-top: 20rpx;margin-left: 30rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 270rpx;">{{item.name}}</view>
							<view style="width: 116rpx;height: 36rpx;background-color: rgba(251, 154, 23, 0.11);margin-top: 20rpx;margin-left: 16rpx;color: #FB9A17;text-align: center;font-size: 24rpx;line-height: 36rpx;border-radius: 4rpx;">待检查{{item.count}}</view>
							<view v-if="item.endTm<nowDate" style="display: flex;">
								<image src="../../static/icon_04@3x.png" style="width: 40rpx;height: 40rpx;margin-left: 80rpx;margin-top: 16rpx;"></image>
								<view style="color: #FB9A17;font-size: 32rpx;line-height: 32rpx;margin-left: 6rpx;margin-top: 20rpx;">已逾期</view>
							</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;color: #E93B3D;margin-top: 16rpx;margin-left: 30rpx;">{{parseInt(item.startTime.split('-')[1])}}月{{parseInt(item.startTime.split('-')[2].split(' ')[0])}}日～{{parseInt(item.endTime.split('-')[1])}}月{{parseInt(item.endTime.split('-')[2].split(' ')[0])}}日截止</view>
						<view style="color: #999999;font-size: 24rpx;line-height: 24rpx;margin-top: 30rpx;margin-left: 30rpx;">创建时间：{{item.createTime}}</view>
					</view>
				</view>
			</view>
			<view v-else style="text-align: center;">
				<image src="../../static/img_empty@2x.png" style="width: 240rpx;height: 240rpx;margin-top: 60rpx;"></image>
				<view style="color: #666666;font-size: 28rpx;margin-top: -60rpx;">暂无检查</view>
			</view>
			<!-- <view style="width: 690rpx;height: 194rpx;margin-top: 30rpx;margin-left: 30rpx;background-color: #FFFFFF;border-radius: 12rpx;">
				<view style="display: flex;">
					<view style="font-size: 36rpx;line-height: 36rpx;margin-top: 30rpx;margin-left: 30rpx;">2021年防汛检查</view>
					<view style="width: 122rpx;height: 36rpx;margin-top: 30rpx;margin-left: 16rpx;font-size:24rpx ;background-color: rgba(251, 154, 23, 0.11);line-height: 36rpx;text-align: center;color: #FB9A17;border-radius: 4rpx;">待检查20</view>
					<image src="../../static/icon_04@3x.png" style="width: 40rpx;height: 40rpx;margin-left: 90rpx;margin-top: 30rpx;"></image>
					<view style="color: #FB9A17;font-size: 32rpx;line-height: 32rpx;margin-left: 6rpx;margin-top: 34rpx;">已逾期</view>
				</view>
				<view style="font-size: 28rpx;line-height: 28rpx;color: #E93B3D;margin-top: 16rpx;margin-left: 30rpx;">12月1日～12月15日截止</view>
				<view style="color: #999999;font-size: 24rpx;line-height: 24rpx;margin-top: 30rpx;margin-left: 30rpx;">创建时间：2021-11-30 12:00:41</view>
			</view> -->
			<view style="width: 690rpx;height: 32rpx;margin-left: 30rpx;margin-top: 60rpx;">
				<view style="float: left;font-size: 32rpx;line-height: 32rpx;">已完成检查</view>
				<image src="../../static/btn-screenArrow@3x.png"style="width: 32rpx;height: 32rpx;float: left;margin-left: 10rpx;"></image>
			</view>
			<view v-if="listY.length!=0">
				<view style="width: 690rpx;margin-top: 30rpx;margin-left: 30rpx;background-color: #FFFFFF;border-radius: 12rpx;padding-bottom: 30rpx;" v-for="(i,index) in listY" :key="i">	
					<view @click="gotoYWC(i.name,i.startTime,i.endTime,i.range)" v-if="i.range!=null">
						<view style="width: 128rpx;height: 40rpx;background-color: #75BC4D;color: #FFFFFF;border-top-left-radius:12rpx;
					border-top-right-radius:0;border-bottom-right-radius:12rpx;border-bottom-left-radius:0;font-size: 26rpx;line-height: 40rpx;text-align: center;">
					区级任务</view>
						<view style="display: flex;">
							<image src="../../static/icon_05@3x.png" style="width: 40rpx;height: 40rpx;margin-left: 26rpx;margin-top: 28rpx;"></image>
							<view style="font-size: 36rpx;line-height: 36rpx;margin-top: 30rpx;margin-left: 6rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 270rpx;">{{i.name}}</view>
							<view style="width: 122rpx;height: 36rpx;margin-top: 30rpx;margin-left: 16rpx;font-size:24rpx ;background-color: rgba(117, 188, 77, 0.12);line-height: 36rpx;text-align: center;color: #75BC4D;border-radius: 4rpx;">已检查{{i.finish}}</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;margin-top: 16rpx;margin-left: 30rpx;">{{parseInt(i.startTime.split('-')[1])}}月{{parseInt(i.startTime.split('-')[2].split(' ')[0])}}日～{{parseInt(i.endTime.split('-')[1])}}月{{parseInt(i.endTime.split('-')[2].split(' ')[0])}}日截止</view>
						<view style="color: #999999;font-size: 24rpx;line-height: 24rpx;margin-top: 30rpx;margin-left: 30rpx;">完成时间：{{i.finishTime}}</view>
					</view>
					<view @click="gotoYWC(i.name,i.startTime,i.endTime,i.range)" v-else>
						<view style="display: flex;">
							<image src="../../static/icon_05@3x.png" style="width: 40rpx;height: 40rpx;margin-left: 26rpx;margin-top: 28rpx;"></image>
							<view style="font-size: 36rpx;line-height: 36rpx;margin-top: 30rpx;margin-left: 6rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 270rpx;">{{i.name}}</view>
							<view style="width: 122rpx;height: 36rpx;margin-top: 30rpx;margin-left: 16rpx;font-size:24rpx ;background-color: rgba(117, 188, 77, 0.12);line-height: 36rpx;text-align: center;color: #75BC4D;border-radius: 4rpx;">已检查{{i.finish}}</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;margin-top: 16rpx;margin-left: 30rpx;">{{parseInt(i.startTime.split('-')[1])}}月{{parseInt(i.startTime.split('-')[2].split(' ')[0])}}日～{{parseInt(i.endTime.split('-')[1])}}月{{parseInt(i.endTime.split('-')[2].split(' ')[0])}}日截止</view>
						<view style="color: #999999;font-size: 24rpx;line-height: 24rpx;margin-top: 30rpx;margin-left: 30rpx;">完成时间：{{i.finishTime}}</view>
					</view>
				</view>
			</view>
			<view v-else style="text-align: center;">
				<image src="../../static/img_empty@2x.png" style="width: 240rpx;height: 240rpx;margin-top: 60rpx;"></image>
				<view style="color: #666666;font-size: 28rpx;margin-top: -60rpx;">暂无检查</view>
			</view>
			<view style="position: fixed;bottom: 0;height: 140rpx;width: 100%;background-color: #FFFFFF;display: flex;" v-if="level==4 || level==5">
				<button style="width: 690rpx;height: 94rpx;color: #FFFFFF;background-color: #519AFF;margin-left: 32rpx;margin-top: 14rpx;border-radius: 47rpx;"@click="gotoJC()">创建新检查</button>
			</view>
		</view>
		<view v-else>
			<view style="width: 690rpx;height: 194rpx;margin-left: 30rpx;background-color: #FFFFFF;border-radius: 12rpx;box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);">
				<view style="width: 128rpx;height: 40rpx;background-image: linear-gradient(to right, #FF952C , #FF4D4F);color: #FFFFFF;border-top-left-radius:12rpx;
				border-top-right-radius:0;border-bottom-right-radius:12rpx;border-bottom-left-radius:0;font-size: 26rpx;line-height: 40rpx;text-align: center;">
				隐患统计</view>
				<view style="display: flex;">
					<view style="height: 94rpx;width: 168rpx;margin-left: 40rpx;" @click="gotoLJ(1,2)">
						<view style="display: flex;flex-direction: row;justify-content: center;">
							<view style="font-size: 52rpx;line-height: 52rpx;color: #FB9A17;margin-top: 20rpx;">{{created+finished}}</view>
							<view style="font-size: 28rpx;line-height: 28rpx;color: #FB9A17;margin-top: 40rpx;margin-left: 10rpx;">个</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;margin-top: 14rpx;">累计发现隐患</view>
					</view>
					<view style="width: 1rpx;height: 40rpx;background-color: #D8D8D8;margin-top: 28rpx;margin-left: 40rpx;"></view>
					<view style="height: 94rpx;width: 112rpx;margin-left: 40rpx;" @click="gotoLJ(2,1)">
						<view style="display: flex;flex-direction: row;justify-content: center;">
							<view style="font-size: 52rpx;line-height: 52rpx;color: #E93B3D;margin-top: 20rpx;">{{created}}</view>
							<view style="font-size: 28rpx;line-height: 28rpx;color: #E93B3D;margin-top: 40rpx;margin-left: 10rpx;">个</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;margin-top: 14rpx;">现存隐患</view>
					</view>
					<view style="width: 1rpx;height: 40rpx;background-color: #D8D8D8;margin-top: 28rpx;margin-left: 40rpx;"></view>
					<view style="height: 94rpx;width: 168rpx;margin-left: 40rpx;" @click="gotoLJ(3,3)">
						<view style="display: flex;flex-direction: row;justify-content: center;">
							<view style="font-size: 52rpx;line-height: 52rpx;color: #60AD35;margin-top: 20rpx;">{{finished}}</view>
							<view style="font-size: 28rpx;line-height: 28rpx;color: #60AD35;margin-top: 40rpx;margin-left: 10rpx;">个</view>
						</view>
						<view style="font-size: 28rpx;line-height: 28rpx;margin-top: 14rpx;">累计整改隐患</view>
					</view>
				</view>
			</view>
			<scroll-view style="width: 690rpx;height: 960rpx;margin-top: 20rpx;margin-left: 30rpx;background-color: #FFFFFF;border-radius: 16rpx;" scroll-y>
				<view style="width: 690rpx;height: 100rpx;" v-for="(e,index) in YHlist" :key="e">
					<view style="display: flex;" @click="gotoLJFX(e.regionId,e.regionName,e.name,areaId,e.id)">
						<view style="float: left;margin-top: 34rpx;margin-left: 30rpx;font-size: 32rpx;line-height: 32rpx;" v-if="areaId<330999999">{{e.regionName}}</view>
						<view style="float: left;margin-top: 34rpx;margin-left: 30rpx;font-size: 32rpx;line-height: 32rpx;" v-else>{{e.name}}</view>
						<view style=" margin-left: auto;width: 150rpx;height: 36rpx;background-color: rgba(251, 154, 23, 0.12);color: #FB9A17;font-size: 24rpx;line-height: 36rpx;text-align: center;border-radius: 4rpx;margin-top: 32rpx;margin-right: 6rpx;">发现隐患{{e.count}}</view>
						<image src="../../static/icon2@3x.png" style="float: right;width: 40rpx;height: 40rpx;margin-top: 30rpx;margin-right: 16rpx;" ></image>
					</view>
					<view style="width: 100%;height: 1rpx; background-color:#E5E5E5 ;margin-top: 30rpx;" v-if="index != YHlist.length-1"></view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				light:true,
				jiedao:'区域选择',
				jiedao1:'鄞州区',
				areaId:'',
				list:[],
				level:'',
				listY:[],
				YHlist:[],
				created:'',
				finished:'',
				date: new Date().toISOString().slice(0, 10),
				nowDate:new Date().getTime(),
				street:0
			}
		},
		methods: {
			Light(){
				this.light=false
			},
			Lights(){
				this.light=true
			},
			goto(){
				uni.navigateTo({
					url:`./areaList?jiedao=${this.jiedao}&light=${this.light}`
				})
			},
			gotoLJ(i,dold){
				console.log(i);
				uni.navigateTo({
					url:`../yinhuan/FXlist?i=${i}&dold=${dold}`
				})
			},
			gotoLJFX(regionId,regionName,name,areaId,id){
				if(name==undefined){
					uni.navigateTo({
						url:`../yinhuan/LJFXyinhuan?regionId=${regionId}&regionName=${regionName}&street=${this.street}`
					})
				}
				else{
					uni.navigateTo({
						url:'../yinhuan/totalXQ?ownerId='+id
					})
				}
				
			},
			async getNme(){
				this.$myRequest({
					url:'/project_flood/v1/check/task/tree',
					data:{"areaId":this.areaId}
				}).then((res)=>{
					console.log(res.data.data.created);
					this.list=res.data.data.created;
					this.listY=res.data.data.finished;
					this.list.forEach(e=>{
						let date = e.endTime
						date = date.split(' ')[0]+' 23:59:59'
						date = date.split('-')
						date = date.join('/')
						e.endTm=new Date(date).getTime()
					})
					
					this.listY.forEach(e=>{
						let date = e.endTime
						date = date.split(' ')[0]+' 23:59:59'
						date = date.split('-')
						date = date.join('/')
						e.endTm=new Date(date).getTime()
					})
				})
			},
			async getYH(){
				if(this.areaId<330999999){
					this.$myRequest({
					url:'/project_flood/v1/check/risk/count_by_region',
					data:{"areaId":this.areaId}
					}).then((res)=>{
						console.log(res);
						this.YHlist=res.data.data
						
					})
				}
				else{
					this.$myRequest({
					url:'/project_flood/v1/check/risk/owner/page',
					data:{"areaId":this.areaId,"pageNum":1,"pageSize":100}
					}).then((res)=>{
						console.log(res);
						this.YHlist=res.data.data.list
						
					})
				}
				
			},
			async getHome(){
				this.$myRequest({
					url: '/project_flood/v1/check/anwser/flood/gridProcess',
					data: {userId: "100000000001", community: "", areaId: this.areaId,timeType:this.timeType},
				}).then((res)=>{
					this.created=res.data.data.created;
					this.finished=res.data.data.finished;
					// console.log(res.data.data.total);
					
				});
			},
			gotoQ(name,range,startTime,endTime){
				uni.navigateTo({
					url:`statistics/JClist?name=${name}&range=${range}&startTime=${startTime}&endTime=${endTime}&areaId=${this.areaId}&areaName=${this.jiedao1}&jiancha=${1}`
				})
			},
			gotoYWC(name,startTime,endTime,range){
				uni.navigateTo({
					url:`./statistics/JClist?name=${name}&startTime=${startTime}&endTime=${endTime}&range=${range}&areaId=${this.areaId}&tan=${1}&reals=${1}`
				})
			},
			gotoJC(){
				uni.navigateTo({
					url:`./benjiJC`
				})
			}
		},
		onLoad(options) {
			console.log(options);
			this.jiedao=options.jiedao
			this.jiedao1=options.jiedao
			this.street=options.street
			if(options.lights!=undefined){
				if(options.lights=='false'){
					this.light=false
				}
			}
			if(options.areaId!=undefined
			){
				this.areaId=options.areaId
			}else{
				try {
				    const X = uni.getStorageSync('areaId');
					const Y = uni.getStorageSync('userName');
					this.areaId=X;
					this.jiedao1=Y;
					this.jiedao=Y;
				    if (X) {
				        // console.log(X);
				    }
					
				} catch (e) {
				    // error
				}
			}
			try {
			    
				const A = uni.getStorageSync('level');
				console.log(this.areaId);
				this.level=A;
			    if (A) {
			        // console.log(X);
			    }
				
			} catch (e) {
			    // error
			}
			
			
		},
		onUnload() {
		   uni.reLaunch({
			  url: '../join/firstpage'   //此处是重新定义返回的路径
		   })
		 },
		onShow() {
			uni.showLoading({
			    title: '加载中'
			});
			console.log('123');
			this.getNme()
		 	this.getYH()
		 	this.getHome().then((res)=>{
				uni.hideLoading();
			})
		 },
	}
</script>

<style>
page{background-color: #F5F5F8;}
</style>
